<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

include_once 'GenericDAO.php';

/**
 * Description of SedeDao
 *
 * @author fabianstevennovoapalomares
 */
class ReservaDao extends GenericDAO{
    
    public function __construct() {
    
        parent::__construct();
    }
    
    
    public function guardarReserva($arrayValores){
        
        return $this->insertarRegistro("tb_reserva", $this->getNombresColumnasXTabla("tb_reserva"), $arrayValores);
        
    }
    
    
    public function borrarReserva($idReserva){
        
        $correcto=true;
        $sqlHabitaciones="DELETE FROM tb_habitacion_has_tb_reserva 
                          WHERE tb_reserva_id_tb_reserva=$idReserva";
        $sqlReserva="DELETE FROM tb_reserva 
        WHERE id_tb_reserva=$idReserva ";
        
        if($this->Conector->onlyRun($sqlHabitaciones)){
            if(!$this->Conector->onlyRun($sqlReserva))
                $correcto=false;
            
        }
        else{
            $correcto=false;
        }
        
        return $correcto;
    }
    
    public function consultarReservas(){
        
        $sql="SELECT 
                tbr.id_tb_reserva, tbr.fecha_reserva, tbc.nombre_cliente
             FROM 
                tb_reserva tbr, tb_cliente tbc
             WHERE
                tbr.tb_cliente_id_tb_cliente=tbc.id_tb_cliente";
        
        return $this->Conector->RetornarArrayFromQuery($sql);
        
    }
    
}

?>